//
//  BCQrAlbumController.m
//  GSBlockChain
//
//  Created by guoshikeji_a on 2019/1/14.
//  Copyright © 2019 guoshikeji. All rights reserved.
//

#import "BCQrAlbumController.h"
//
#import "BCQrImagePickerViewController.h"

@interface BCQrAlbumController () <BCQrImagePickerViewControllerDelegate>

@property (nonatomic, copy) BCQrAlbumIdentificationComplete idenitificationComplete;

@end

@implementation BCQrAlbumController

+ (void)showAlbumWithPrentingController:(UIViewController *)prentingController complete:(BCQrAlbumIdentificationComplete)complete {
    if (!prentingController) {
        return;
    }
    BCQrAlbumController *albumVC = [BCQrAlbumController new];
    albumVC.idenitificationComplete = complete;
    BCAlbumNavigationController *nav = [[BCAlbumNavigationController alloc] initWithRootViewController:albumVC];
    [prentingController presentViewController:nav animated:true completion:nil];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}


#pragma mark - QMUIAlbumViewControllerDelegate
/// 点击相簿里某一行时，需要给一个 QMUIImagePickerViewController 对象用于展示九宫格图片列表
- (QMUIImagePickerViewController *)imagePickerViewControllerForAlbumViewController:(QMUIAlbumViewController *)albumViewController {
    BCQrImagePickerViewController *imagePickerVC = [BCQrImagePickerViewController new];
    imagePickerVC.addressDelegate = self;
    return imagePickerVC;
}


#pragma mark - BCQrImagePickerViewControllerDelegate
- (void)recognitionedValidAddress:(NSString *)address {
    [self.navigationController dismissViewControllerAnimated:true completion:^{
        if (self.idenitificationComplete) {
            self.idenitificationComplete(address);
        }
    }];
}

@end
